package thread.demo01;

import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.net.URL;

/**
 * 练习 多线程图片下载
 */
@AllArgsConstructor
public class DjxTestThread02 extends Thread {

    private String url;
    private String name;


    @Override
    public void run() {
        downLoader.downLoader(url, name);
        System.out.println("下载了文件名为：" + name);
    }

    public static void main(String[] args) {
        new DjxTestThread02("", "").start();
        new DjxTestThread02("", "").start();
        new DjxTestThread02("", "").start();
    }

}

/**
 * 下载器
 */
class downLoader {

    @SneakyThrows
    public static void downLoader(String url, String name) {
        FileUtils.copyURLToFile(new URL(url), new File(name));
    }

}
